1. /* snmcutdn.cpp by K.Tsuru */
  2. //function ID=106,107
  3. /**********************************************
  4. SNumber class
  5. CutDown()
  6. It reduces size by removing unnecessary zeros.
  7. ***********************************************/
  8. #ifndef SN_H
  9. #include "sn.h"
  10. #endif
  11. // DETECT_IR = 3 in SNManager class
  12. bool SNumber::cutDownTable[SNManager::DETECT_IR] = {DISABLE, ENABLE, ENABLE};
  13. // function ID = 106
  14. void SNumber::CutDown(uchar cd) {
  15. if(type == BIN_DEC) return; // SDecimal always DISABLE.
  16. int tp = type & DETECT_IR;
  17. #ifndef NDEBUG
  18. assert(tp);
  19. #endif
  20. if(cd == POP){
  21. if(pushCD & PUSH){
  22. pushCD &= ~PUSH;
  23. cutDownTable[tp] = (cutDownTable[tp] == ENABLE) ? DISABLE : ENABLE;
  24. }
  25. } else { // here cd == DISABLE (false) or ENABLE(true)
  26. // if( cd != (cutDownTable[tp]){
  27. uchar temp = cutDownTable[tp] ? 1u : 0; // for the warning by visual c++ since ver 2.19
  28. if( cd != temp){
  29. cutDownTable[tp] = (cutDownTable[tp] == ENABLE) ? DISABLE : ENABLE;
  30. pushCD |= PUSH;
  31. }
  32. }
  33. }
  34. // function ID = 107
  35. //It removes unnecessary zeros.
  36. //necessary size = aHead+1
  37. void SNumber::DoCutDown(){
  38. if(CutDown() == DISABLE) return;
  39. if( figure.size() <= minArraySize ) return; //cannot reduce size
  40. if( 2u*(aHead+1) <= figure.size() ) valloc( aHead+1, 1);
  41. }

snmcutdn.cpp : last modifiled at 2016/09/04 14:21:43(1,289 bytes)
created at 2016/04/11 11:36:47
The creation time of this html file is 2017/10/27 10:59:17 (Fri Oct 27 10:59:17 2017).